#!/bin/bash

here=`dirname $0`
cvc4=$here/cvc4
bench="$1"

file=${bench##*/}
filename=${file%.*}

echo "------- cvc4-fof casc j8 : $bench at $2..."

# use: trywith [params..]
# to attempt a run.  If an SZS ontology result is printed, then
# the run script terminates immediately.  Otherwise, this
# function returns normally.
function trywith {
  limit=$1; shift;
  echo "--- Run $@ at $limit...";
  (ulimit -S -t "$limit";$cvc4 --lang=tptp --no-checking --no-interactive --dump-instantiations --inst-format=szs --force-no-limit-cpu-while-dump "$@" $bench) 2>/dev/null |
  (read w1 w2 w3 result w4 w5;
  case "$result" in
  Unsatisfiable) echo "$w1 $w2 $w3 $result $w4 $w5";cat;exit 0;;
  Theorem) echo "$w1 $w2 $w3 $result $w4 $w5";cat;exit 0;;
  esac; exit 1)
  if [ ${PIPESTATUS[1]} -eq 0 ]; then exit 0; fi
}
function finishwith {
  echo "--- Run $@...";
  $cvc4 --lang=tptp --no-checking --no-interactive --dump-instantiations --inst-format=szs --force-no-limit-cpu-while-dump "$@" $bench
}

# designed for 300 seconds
trywith 20 --relational-triggers --full-saturate-quant 
trywith 20 --no-e-matching --full-saturate-quant 
trywith 15 --finite-model-find --mbqi=abs
trywith 5 --multi-trigger-when-single --full-saturate-quant 
trywith 5 --trigger-sel=max --full-saturate-quant
trywith 5 --multi-trigger-when-single --multi-trigger-priority --full-saturate-quant  
trywith 10 --finite-model-find --uf-ss=no-minimal --sort-inference --uf-ss-fair
trywith 10 --term-db-mode=relevant --full-saturate-quant
trywith 15 --prenex-quant=none --full-saturate-quant
trywith 15 --decision=internal --full-saturate-quant
trywith 30 --relevant-triggers --full-saturate-quant 
trywith 30 --finite-model-find --fmf-inst-engine --sort-inference --uf-ss-fair
trywith 30 --fs-inst --full-saturate-quant
trywith 30 --no-quant-cf --full-saturate-quant 
finishwith --qcf-vo-exp --full-saturate-quant 
# echo "% SZS status" "GaveUp for $filename"
